#include <iostream>
#include <cstdio>
#include <pthread.h>
#include <unistd.h>
using namespace std;

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

void* start_routine(void* args) {
    pthread_mutex_lock(&mutex);

    printf("%p %s\n", pthread_self(), "in start_routine");
    sleep(3); //* 事实验证，就算线程被挂起了也不会释放互斥锁
    pthread_mutex_unlock(&mutex);

    return nullptr;
}


int main() {
    pthread_t thread1, thread2;
    pthread_create(&thread1, nullptr, start_routine, nullptr);
    pthread_create(&thread2, nullptr, start_routine, nullptr);

    pthread_join(thread1, nullptr);
    pthread_join(thread2, nullptr);
    return 0;
}